<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>


<style>
<!--
.notification_box  li {
	height: 30px; padding: 0px; background: #f8f8f8; float: left; width: 90px; margin-left: 10px; position: relative; border: 1px solid #ccc;
}

.notification_box .firstli {
	position: absolute; min-width: 50px; left: 3px; line-height: 31px; text-align: center;
}

.notification_box .secli {
	color: #fff; position: absolute; right: 0; width: 30px; background: #48ac2e; height: 30px; text-align: center; line-height: 31px; position: absolute;
}

html {
	overflow: auto
}
-->
</style>


<script type="text/javascript">
	function incidentGridActions(rowObject) {
		if (rowObject.stauts != "已关闭" &&rowObject.process_id) {
			return isperp.createGridAction({
				title : '转派人员',
				iconCls : 'icon-change',
				onclick :  "isperp.workflow.transferAssignee('" + rowObject.process_id + "')"
			})+isperp.createGridAction({
				title : '修改内容',
				iconCls : 'icon-config',
				onclick : "isperp.openDialog({contentUrl:'incident/incident/edit?id=" + rowObject.id + "&projectId=" + rowObject.project_id + "&state=false&processKey=incidentProcess'})"
			});
		}else{
			return "";
		}

	}
	
	function checkDelete(rowid)
	{
	  var result=false;
	  $.ajax({
	    url:'incident/incident/checkDelete?id='+rowid,
	    async: false,
	    success:function(data)
	    {
	       if(data.success)
	       {
	         result=true;
	       }else
	       {
	         isperp.alert("非草稿状态下的不能删除！");
	         result=false;
	       }
	    }
	  });
	  return result;
	}
	
</script>

<isperp:grid url="incident/main/serviceDeskNewIncidentList"
	actionsWidth="70" gridId="incidentGrid" processKey="incidentProcess"
	sortname="create_date" sortorder="desc" autowidth="false"
	ondbClickRowEvent="incidentGrid.edit(rowid);" autoReloadGrid="true"
	autoReloadTreeMenu="incidentMenu" cusViewUrl="incident/incident/view"
	advanceSearch="true" cusDeleteUrl="incident/incident/delete"
	beforeDeleteAction="checkDelete(rowid)"
	keywordFields="a.code,title,description,ci_code,c.code,c.name"
	keywordTitle="输入编号/标题/描述">

	<jsp:attribute name="toolbar">
	<isperp:treeMenu id="incidentMenu" targetGridId="incidentGrid">
		<isperp:async enable="true"
				url="incident/main/serviceDeskNewIncidentMenu"></isperp:async>
		<isperp:callback onClick="incidentMenuTree_onNodeClick"
				onAsyncSuccess="incidentMenuTree_onNodeClickFirst();">
		</isperp:callback>
	</isperp:treeMenu>
	    
 
	<button id="roleCreate" type="button" class="button  nui-mainbtn"
			onclick="incidentGrid.create();return false;">
			<span class="icon icon-plus"></span>事件登记</button>
	</jsp:attribute>

	<jsp:attribute name="searchbar">
	 <table class="search-table">
		<tbody>
			<tr>
				<td class="td1">编号：</td>
				<td class="td2"><input type="text" field="code" op="cn">
					</td>
				<td class="td1">标题：</td>
				<td class="td2"><input type="text" field="title" op="cn">
					</td>
				<td class="td1">性质：</td>
				<td class="td2">
				   <isperp:dictSelector id="incidentType" field="incident_type"
							multiple="true" op="cn" typeCode="INCIDENT_NATURE"></isperp:dictSelector>
				</td>
			</tr>
			<tr>
				<td class="td1">申报人：</td>
				<td class="td2"><input type="text" field="cus_user_name"
						op="cn">
					</td>
				<td class="td1">请求时间：</td>
				<td class="td2"><input id="createDateStart" type="date"
						class="date" field="create_date" op="gt" style="width: 68px" />~<input
						id="createDateEnd" class="date" type="date" field="create_date"
						op="lt" style="width: 68px" />
				</td> 
			 <td class="td1">状态：</td>
				<td class="td2"><isperp:dictSelector id="status" field="status"
							multiple="true" op="cn" typeCode="INCIDENT_STATUS"></isperp:dictSelector>
				</td>
			</tr>
			
			
		</tbody>
	</table>
	</jsp:attribute>
	<jsp:body>
	<isperp:column name="id" title="" hidden="true"></isperp:column>
	<isperp:column name="process_id" title="" hidden="true"></isperp:column>
	<isperp:column name="sla_status" title="" hidden="true"></isperp:column>
	<isperp:column name="priority_name" title="" width="40"
			isFormatterFun="true" formatter="return statusFormatter(rowObject);">
	</isperp:column>
	<isperp:column name="code" title="编号" width="110">
	</isperp:column>
	<isperp:column name="title" title="标题" width="120">
	</isperp:column>
	<isperp:column name="icd_category_name" title="事件分类" width="80">
	</isperp:column>
		<isperp:column name="incident_type" title="性质" width="50">
	</isperp:column>
	<isperp:column name="cus_customer_name" title="申报单位" width="70">
	</isperp:column>
	<isperp:column name="cus_user_name" title="申报人" width="60">
	</isperp:column>
	<isperp:column name="supporter_name" title="工程师" width="60">
	</isperp:column>
	<isperp:column name="creator_name" title="创建人" width="60">
	</isperp:column>
	<isperp:column name="create_date" title="创建时间" width="110">
	</isperp:column>
	<isperp:column name="status" title="状态" width="80">
	</isperp:column>
	</jsp:body>
</isperp:grid>

<script type="text/javascript">
	function statusFormatter(rowObject) {
		var p = 0, html = "", title = "";
		if (rowObject.priority_name != null) {

			switch (rowObject.priority_name) {
			case "一级":
				p = 1;
				break;
			case "二级":
				p = 2;
				break;
			case "三级":
				p = 3;
				break;
			case "四级":
				p = 4;
				break;
			case "五级":
				p = 5;
				break;
			}
			title = "优先级：" + p + "级";
		} else {
			title = "未确定优先级";
		}

		html = "<img title='"+title+"' src='img/incident/p"+p+".png'>";
		if (rowObject.sla_status == 1) {

			html = html + "&nbsp;<img title='SLA：异常'  src='img/incident/sla_unusual.png'>";
		}
		return html + "&nbsp;<a id='msg_" + rowObject.id + "' href=\"javascript:openRelationMessage('" + rowObject.id + "')\" class=''></a>";
	}

	function openRelationMessage(id) {

		isperp.openDialog({
			title : "查看消息",
			contentUrl : "app/message/relationMessageView?all=1&sourceId=" + id
		});
	}

	incidentGrid.contextMenu = function(rowid, iRow, iCol, e) {
		var data = [[ {
			text : "图片内间距",
			func : function() {
				alert(1)
				$(this).css("padding", "10px");
			}
		} ]];
		$("body").smartMenu(data );
	}
</script>